<?php

namespace App\Admin\Renderable;

use App\Models\PaperLibrary;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class PaperLibraryTable extends LazyRenderable
{
    public function grid(): Grid
    {
        $regionId = $this->payload['region_id'];

        return Grid::make(new PaperLibrary(), function (Grid $grid) use ($regionId) {
            if ($regionId) {
                $grid->model()->whereIn('region_id', [0, $regionId]);
            }
            $grid->column('id', 'ID')->sortable();
            $grid->column('paper_title', '标题');
//            $grid->column('paper_remark', '备注');
            $grid->column('created_at');

            $grid->quickSearch(['id', 'paper_title']);

            $grid->paginate(10);
            $grid->disableActions();
        });

    }
}